public class Solution {
    public int maxChunksToSorted(int[] arr) {
        int m = 0, res = 0;
        for (int i = 0; i < arr.length; i++) {
            m = Math.max(m, arr[i]);
            if (m == i) {
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {4, 3, 2, 1, 0}; 
        int result = solution.maxChunksToSorted(arr);
        System.out.println("最大可分割的块数为: " + result);
    }
}
